#include<cstdio>
#include<cstring>
const int maxn=600;
double f[maxn],g[maxn];
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		memset(f,0,sizeof(f));
		memset(g,0,sizeof(g));
		int n,k1,k2,k3,a,b,c;
		scanf("%d%d%d%d%d%d%d",&n,&k1,&k2,&k3,&a,&b,&c);
		double p=k1*k2*k3;
		p=1.0/p;
		for(int i=n;i>=0;i--)
		{
			for(int a1=1;a1<=k1;a1++)
				for(int a2=1;a2<=k2;a2++)
					for(int a3=1;a3<=k3;a3++)
					{
						if((a1==a&&a2==b&&a3==c))continue;
						f[i]+=f[i+a1+a2+a3]*p;
						g[i]+=g[i+a1+a2+a3]*p;
					}
			f[i]+=p;
			g[i]+=1;
		}

		printf("%0.15lf\n",g[0]/(1-f[0]));
	}
	return 0;
}
						
					

